package gui;

import java.awt.Dimension;
import java.awt.GridLayout;
import java.util.Iterator;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import containers.StudentContainer;
import entities.Manager;
import entities.Student;

/**
 * 
 * @author Samuel Ferguson sff803
 * 
 */
public class GenerateStatementPanel extends JPanel {
	Object[][] data;

	public GenerateStatementPanel() {
		super(new GridLayout(1, 0));

		String[] columnNames = { "ID", "Loan Amount", "Monthly Payout" };

		data = new Object[StudentContainer.dictionary().size()][columnNames.length];
		Iterator<Student> iter = StudentContainer.dictionary().values()
				.iterator();
		int i = 0;
		while (iter.hasNext()) {
			Student temp = iter.next();
			if (!temp.getLoan().isNew()) {
				data[i][0] = temp.getID();
				data[i][1] = temp.getLoan().getAmountGiven();
				data[i][2] = temp.getLoan().getAmountGiven() / 12;
				i++;
			}
		}

		Manager.table = new JTable(data, columnNames);
		Manager.table
				.setPreferredScrollableViewportSize(new Dimension(500, 70));
		Manager.table.setFillsViewportHeight(true);

		// Create the scroll pane and add the table to it.
		JScrollPane scrollPane = new JScrollPane(Manager.table);

		// Add the scroll pane to this panel.
		add(scrollPane);
	}

	private static final long serialVersionUID = 1;

}
